/**
 * ErrorCode.java
 *
 * Purpose              :
 *
 * Optional info        :
 *
 * @author              : Van Hoang Phuong
 *
 * @date                : May 31, 2012
 *
 * @lastChangedRevision :
 *
 * @lastChangedDate     :
 *
 */
package com.aplink.dellcommercial.webservices;

/**
 * @author Hoang Viet
 */
public enum ErrorCode {
    DID_NOT_LOGIN( 6 ),
    JSON_PARSE_ERROR( 7 ),
    LOGIN_FAILED( 8 ),
    NETWORK_ERROR( 1 ),
    NETWORK_LOST( 5 ),
    NO_ERROR( 0 ),
    SERVER_ERROR( 2 ),
    TIME_OUT( 4 ),
    UNKNOWN_ERROR( 3 );

    private int mErrorCode;

    public static ErrorCode getErrorCode( int errorCode ) {
        switch ( errorCode ) {
            case 0:
                return ErrorCode.NO_ERROR;
            case 1:
                return ErrorCode.NETWORK_ERROR;
            case 2:
                return ErrorCode.SERVER_ERROR;
            case 3:
                return ErrorCode.UNKNOWN_ERROR;
            case 4:
                return ErrorCode.TIME_OUT;
            case 5:
                return ErrorCode.NETWORK_LOST;
            case 6:
                return ErrorCode.DID_NOT_LOGIN;
            case 7:
                return ErrorCode.JSON_PARSE_ERROR;
            case 8:
                return ErrorCode.LOGIN_FAILED;
            default:
                return ErrorCode.UNKNOWN_ERROR;
        }
    }

    ErrorCode( int errorCode ) {
        this.mErrorCode = errorCode;
    }

    @Override
    public String toString() {
        switch ( this.mErrorCode ) {
            default:
                return "ERROR";
        }
    }
}
